#ifndef _PCIE_ALT_H
#define _PCIE_ALT_H

#include "..\dma_config.h"
#include "qsys_lib_1210.h"

#define ALTERA_PCIE_V800_ID			0xE001 /* V801/802 Device ID */
#define ALTERA_PCIE_D901_ID			0x0901 /* D901 special Device ID */

#ifdef __cplusplus
extern "C" {
#endif

int PcieCountCards(WORD deviceId);
WDC_DEVICE_HANDLE PcieOpenDevice(int iSlot, WORD deviceId);
void PcieCloseDevice(WDC_DEVICE_HANDLE hDev);
void PcieDelay(WDC_DEVICE_HANDLE hDev, int us);
DWORD PcieReadIo(WDC_DEVICE_HANDLE hDev, DWORD addr);
void PcieWriteIo(WDC_DEVICE_HANDLE hDev, DWORD addr, DWORD dwData);
WORD PcieReadReg16(WDC_DEVICE_HANDLE hDev, DWORD addr);
void PcieWriteReg16(WDC_DEVICE_HANDLE hDev, DWORD addr, WORD wData);

void PcieDmaInit(WDC_DEVICE_HANDLE hDev, DmaConfig *dmaConfig);
DWORD PcieDmaReadOpen(WDC_DEVICE_HANDLE hDev);
void PcieDmaReadStart(WDC_DEVICE_HANDLE hDev, int flag);
BOOL PcieDmaIsDone(WDC_DEVICE_HANDLE hDev);
BOOL PcieDmaTransfer(WDC_DEVICE_HANDLE hDev, DWORD *pDmaBlock, size_t blockLen);
void PcieDmaReadEnd(WDC_DEVICE_HANDLE hDev);
void PcieDmaReadClose(WDC_DEVICE_HANDLE hDev);

#ifdef __cplusplus
}
#endif

#endif
